home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / PRGMMING / CPP100.ZIP / CPPFIC3.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-22  |  7.0 KB  |  180 lines

  1. /*****************************************************************************/
  2. /*       (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved         */
  3. /*****************************************************************************/
  4. /*    This source-code is NOT public domain nor Freeware, this is part of    */
  5. /*              'The C Programming Package' which is Shareware.              */
  6. /*   If you use this code, please register and get a free Full-VGA version   */
  7. /*****************************************************************************/
  8.                         /*------------------------*
  9.                          *         CPPFIC3.C      *
  10.                          *       FILE MANAGER     *
  11.                          * Recording of the saves *
  12.                          *  Changes in Help file  *
  13.                          *------------------------*/
  14.  
  15.  /* Included Files */
  16.  # include <stdio.h>
  17.  # include <io.h>
  18.  # include <dos.h>
  19.  # include <fcntl.h>
  20.  # include <bios.h>
  21.  # include <stdlib.h>
  22.  # include <conio.h>
  23.  # include <dir.h>
  24.  # include <string.h>
  25.  # include <alloc.h>
  26.  # include <mem.h>
  27.  
  28.  /* Global Variables */
  29.  extern int bm,i,j,k,l,m,n,t,x,xm,y,ym,z,menu0,menu1,return1;
  30.  extern int colour1,colour2,colour3,colour4,colour5,nbdisk,return2,return3,recording;
  31.  extern int lline,linemax,choice,modif,pfdiv,pfserv,pfhelp,returning;
  32.  extern unsigned int ref,nbref,nbrep;
  33.  extern long dep,depdiv,dephelp;
  34.  extern unsigned long nbbytes;
  35.  extern unsigned char c0,c1,trashcan[],path[],nc1[],trashret[],filedir[];
  36.  extern unsigned char work[],record[],saverep[];
  37.  extern struct ffblk ffblk;
  38.  
  39.  /*-------------------*
  40.   * BLANK LINE 25 *
  41.   *-------------------*/
  42.   void blank_line_25()
  43.     {
  44.       textattr(colour1);                 gotoxy(1,25);
  45.       cputs("                                                                            ");
  46.     }
  47.  /*-----------------------------------*
  48.   * CONFIRM RECORDING DIRECTORY *
  49.   *-----------------------------------*/
  50.   int confirm_recording_directory()
  51.     {
  52.       /* Display the selected directory */
  53.       blank_line_25();             textattr(colour3);
  54.       gotoxy(1,25);                    cputs("Record dir= ");
  55.       gotoxy(13,25);                   cputs(record);
  56.       /* Ask the confirmation of the destination */
  57.       l=message(" Recording to"," the directory"," at the bottom"," Confirm Please"," Yes  or  No  Y/N");
  58.       if(l==-1)                        return(-1);
  59.       if(l==34)                        return(1);
  60.       if((l==100)&&(ym==21)&&(xm>51)&&(xm<57))  return(1);
  61.       /* If we do not agree we can type another directory */
  62.       blank_line_25();             textattr(colour3);
  63.       gotoxy(1,25);                    cputs("Record dir= ");
  64.       strcpy(trashcan,record);
  65.       l=get_or_change_a_word(13,25,64);
  66.       if(l==1){
  67.        /* We confirmed a directory */
  68.         strcpy(record,trashret);      return(1);
  69.       }
  70.       else                             return(0);
  71.     }
  72.  /*-------------------------------*
  73.   * FULL RECORDING PATH *
  74.   *-------------------------------*/
  75.   int full_recording_path()
  76.     {
  77.       strcpy(saverep,record);        j=strlen(saverep);
  78.       /* Cut the spaces at the end of the word */
  79.       for(i=j; i>0; i--){
  80.         c1=saverep[i];
  81.         if((c1==0x20)||(c1==0x00))     saverep[i]=0x00;
  82.     else                           break;
  83.       }
  84.       /* Create a path by adding the date to the path name */
  85.       get_date_text_format();       nc1[2]=0x00;
  86.       nc1[0]=trashcan[0];              nc1[1]=trashcan[1];
  87.       strcat(saverep,nc1);
  88.       nc1[0]=trashcan[3];              nc1[1]=trashcan[4];
  89.       strcat(saverep,nc1);
  90.       nc1[0]=trashcan[6];              nc1[1]=trashcan[7];
  91.       strcat(saverep,nc1);            c0=65;
  92.       while(1){
  93.     nc1[0]=c0;                     nc1[1]=0x00;
  94.         strcpy(filedir,saverep);       strcat(filedir,nc1);
  95.         /* Check the name to be sure that this directory does not exist yet */
  96.         strcat(filedir,"\\*.*");
  97.         j=findfirst(filedir,&ffblk,0x37);
  98.     if(j==-1){
  99.           /* It does not exist yet, then add the suffix to the path */
  100.           strcat(saverep,nc1);        break;
  101.     }
  102.         /* Else increment the indice B, C, D, etc.  (last : Z) */
  103.     c0++;
  104.     if(c0>90){
  105.           /* We are after Z */
  106.           warning(" Too many files"," in this directory"," Enter another"," directory name"," Click or press a key");
  107.       break;
  108.     }
  109.       }
  110.       blank_line_25();             textattr(colour3);
  111.       gotoxy(1,25);                    cputs("Record dir= ");
  112.       gotoxy(13,25);                   cputs(saverep);
  113.       l=message(" Recording to"," the directory"," at the bottom"," Confirm Please"," Yes  or  No  Y/N");
  114.       if(l==-1)                        return(-1);
  115.       if(l==34)                        return(1);
  116.       if((l==100)&&(ym==21)&&(xm>51)&&(xm<57))  return(1);
  117.       /* If we do not agree we can type another directory */
  118.       blank_line_25();             textattr(colour3);
  119.       gotoxy(1,25);                    cputs("Record dir= ");
  120.       strcpy(trashcan,saverep);
  121.       l=get_or_change_a_word(13,25,64);
  122.       if(l==1){
  123.        /* We confirmed a directory */
  124.         strcpy(saverep,trashret);     return(1);
  125.       }
  126.       else                             return(0);
  127.     }
  128.  /*------------------------------*
  129.   *         FILE RECORDING       *
  130.   * Function 7 of the Files menu *
  131.   *------------------------------*/
  132.   void file_recording()
  133.     {
  134.       /* Active the variable which confirms the recording */
  135.       recording=1;
  136.       returning=confirm_recording_directory();
  137.       if(returning<1)                     return;
  138.       returning=full_recording_path();
  139.       if(returning<1)                     return;
  140.       /* If everything is OK, then create the directory */
  141.       returning=mkdir(saverep);
  142.       if(returning<0)                     return;
  143.       /* Now, the recording is made */
  144.       directory_change();
  145.     }
  146.  /*--------------------------------*
  147.   * CREATE FILE FOR ON-LINE HELP *
  148.   *--------------------------------*/
  149.   void create_on_line_help_file()
  150.     {
  151.       FILE *fileread,*filewrite;
  152.       /* As we do not want to take too much place on the drive, */
  153.       /* we copy directly in the HELP.FIC file */
  154.       l=2;
  155.       if((fileread=fopen("HELP.TXT","r"))==NULL){
  156.         warning(" Cannot open"," the file HELP.TXT"," for reading"," Press a key"," or click");
  157.     return;
  158.       }
  159.       if((filewrite=fopen("HELP.FIC","wb"))==NULL){
  160.         warning(" Cannot open"," the file HELP.FIC"," for an update"," Press a key"," or click");
  161.     return;
  162.       }
  163.       while((fread(trashcan,1,l,fileread))==2){
  164.     m=0;
  165.     for(x=0; x<l; x++){
  166.           c0=trashcan[x];
  167.       if(c0!=0x0d){
  168.         if(c0!=0x0a){
  169.               trashret[m]=c0;
  170.           m++;
  171.         }
  172.       }
  173.     }
  174.         fwrite(trashret,1,m,filewrite);
  175.       }
  176.       fwrite(trashret,1,m,filewrite);
  177.       fclose(fileread);                     fclose(filewrite);
  178.     }
  179. /* End of Module *//*------------------------*/
  180.